﻿// Write a program that reads a text file containing a list of strings, 
// sorts them and saves them to another text file. 
// Example:
//	Ivan			George
//	Peter			Ivan
//	Maria			Maria
//	George			Peter

using System;
using System.IO;

class SortTextFileListOfString
{
    static void Main()
    {
        string path = @"..\..\";

        string inputFileName = "UnsortedStringList.txt";
        string inputFile = Path.Combine(path, inputFileName);

        string outputFileName = "SortedStringList.txt";
        string outputFile = Path.Combine(path, outputFileName);

        try
        {
            string[] stringList = File.ReadAllLines(inputFile);
            Array.Sort(stringList);
            File.WriteAllLines(outputFile, stringList);
            Console.WriteLine("File content is sorted in new file: {0}", outputFile);
        }
        catch (Exception exc)
        {
            Console.WriteLine(exc.Message);
        }

    }
}